package domain.entities;

import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;

import javax.persistence.*;
import java.util.*;

/**
 * ProtocoloCompromisopais entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "protocolo_compromisopais", catalog = "bms")
public class ProtocoloCompromisopais implements java.io.Serializable {

	// Fields
	private ProtocoloCompromisopaisId id;
	private Scorecard scorecard;
	private Compromisopais compromisopais;
	private Protocolo protocolo;
    private Integer commitment;
	private Date plannedFpfv;
	private Date plannedLpfv;
    private Date plannedLplv;
	private String status;
    private String comments;
    private Set<ProtocoloCentro> protocoloCentros = new HashSet<ProtocoloCentro>(
			0);
	private List<Objetivo> objetivos = new ArrayList<Objetivo>();
	private Set<Trackingtraducciones> trackingtraduccioneses = new HashSet<Trackingtraducciones>(
			0);
	private Set<MiembroBmsProtocolo> miembroBmsProtocolos = new HashSet<MiembroBmsProtocolo>(
			0);
    private List<EnrolledPatients> enrolledPatients = new ArrayList<EnrolledPatients>();
    private List<EquipmentSiteProtocoloCompromisoPais> equipments;


//    private Collection<Vendorcentral> vendors;

    // Constructors

	/** default constructor */
	public ProtocoloCompromisopais() {
	}

	/** minimal constructor */
	public ProtocoloCompromisopais(ProtocoloCompromisopaisId id,
			Scorecard scorecard, Compromisopais compromisopais,
			Protocolo protocolo, String status) {
		this.id = id;
		this.scorecard = scorecard;
		this.compromisopais = compromisopais;
		this.protocolo = protocolo;
		this.status = status;
	}

	/** full constructor */
	public ProtocoloCompromisopais(ProtocoloCompromisopaisId id,
                                   Scorecard scorecard, Compromisopais compromisopais,
                                   Protocolo protocolo,
                                   Integer commitment,
                                   Date plannedFpfv, Date plannedLpfv,
                                   String status, String comments,
                                   Collection<Vendorcentral> vendorcentrals,
                                   Set<ProtocoloCentro> protocoloCentros, List<Objetivo> objetivos,
                                   Set<Trackingtraducciones> trackingtraduccioneses,
                                   Set<MiembroBmsProtocolo> miembroBmsProtocolos,
                                   List<EnrolledPatients> enrolledPatients) {
		this.id = id;
		this.scorecard = scorecard;
		this.compromisopais = compromisopais;
		this.protocolo = protocolo;
		this.commitment = commitment;
		this.plannedFpfv = plannedFpfv;
		this.plannedLpfv = plannedLpfv;
		this.status = status;
        this.comments = comments;
//		this.vendors = vendorcentrals;
		this.protocoloCentros = protocoloCentros;
		this.objetivos = objetivos;
		this.trackingtraduccioneses = trackingtraduccioneses;
		this.miembroBmsProtocolos = miembroBmsProtocolos;
        this.enrolledPatients = enrolledPatients;
	}


	// Property accessors
	@EmbeddedId
	@AttributeOverrides( {
			@AttributeOverride(name = "protocoloid", column = @Column(name = "protocoloid", nullable = false)),
			@AttributeOverride(name = "compromisopaisid", column = @Column(name = "compromisopaisid", nullable = false)) })
	public ProtocoloCompromisopaisId getId() {
		return this.id;
	}

	public void setId(ProtocoloCompromisopaisId id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
	@JoinColumn(name = "scorecardid")
	public Scorecard getScorecard() {
		return this.scorecard;
	}

	public void setScorecard(Scorecard scorecard) {
		this.scorecard = scorecard;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "compromisopaisid", nullable = false, insertable = false, updatable = false)
	public Compromisopais getCompromisopais() {
		return this.compromisopais;
	}

	public void setCompromisopais(Compromisopais compromisopais) {
		this.compromisopais = compromisopais;
	}

	@ManyToOne()
    @LazyCollection(LazyCollectionOption.FALSE)
	@JoinColumn(name = "protocoloid", nullable = false, insertable = false, updatable = false)
	public Protocolo getProtocolo() {
		return this.protocolo;
	}

	public void setProtocolo(Protocolo protocolo) {
		this.protocolo = protocolo;
	}

    @Column(name = "commitment")
	public Integer getCommitment() {
		return this.commitment;
	}

	public void setCommitment(Integer commitment) {
		this.commitment = commitment;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "plannedFPFV", length = 10)
	public Date getPlannedFpfv() {
		return this.plannedFpfv;
	}

	public void setPlannedFpfv(Date plannedFpfv) {
		this.plannedFpfv = plannedFpfv;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "plannedLPFV", length = 10)
	public Date getPlannedLpfv() {
		return this.plannedLpfv;
	}

	public void setPlannedLpfv(Date plannedLpfv) {
		this.plannedLpfv = plannedLpfv;
	}

    @Temporal(TemporalType.DATE)
    @Column(name = "plannedLPLV", length = 10)
    public Date getPlannedLplv() {
        return this.plannedLplv;
    }

    public void setPlannedLplv(Date plannedLplv) {
        this.plannedLplv = plannedLplv;
    }


	@Column(name = "status")
	public String getStatus() {
		return this.status;
	}

	public void setStatus(String status) {
		this.status = status;
	}


    @OneToMany(mappedBy = "protocoloCompromisopais")
    @LazyCollection(LazyCollectionOption.FALSE)
    public Set<ProtocoloCentro> getProtocoloCentros() {
		return this.protocoloCentros;
	}

	public void setProtocoloCentros(Set<ProtocoloCentro> protocoloCentros) {
		this.protocoloCentros = protocoloCentros;
	}

	@OneToMany(mappedBy = "protocoloCompromisopais")
    @LazyCollection(LazyCollectionOption.FALSE)
    public Set<Trackingtraducciones> getTrackingtraduccioneses() {
		return this.trackingtraduccioneses;
	}

	public void setTrackingtraduccioneses(
			Set<Trackingtraducciones> trackingtraduccioneses) {
		this.trackingtraduccioneses = trackingtraduccioneses;
	}

	@OneToMany(mappedBy = "protocoloCompromisopais")
    @LazyCollection(LazyCollectionOption.FALSE)
    public Set<MiembroBmsProtocolo> getMiembroBmsProtocolos() {
		return this.miembroBmsProtocolos;
	}

	public void setMiembroBmsProtocolos(
			Set<MiembroBmsProtocolo> miembroBmsProtocolos) {
		this.miembroBmsProtocolos = miembroBmsProtocolos;
	}


//    @OneToMany(mappedBy = "protocolo")
//    @LazyCollection(LazyCollectionOption.FALSE)
//    public Collection<Vendorcentral> getVendors() {
//        return vendors;
//    }
//
//    public void setVendors(Collection<Vendorcentral> vendors) {
//        this.vendors = vendors;
//    }

    @Column(name = "comments")
    public String getComments() {
        return comments;
    }

    public void setComments(String comments) {
        this.comments = comments;
    }


    @OneToMany(mappedBy = "protocoloCompromisopais")
    @LazyCollection(LazyCollectionOption.FALSE)
    public List<EnrolledPatients> getEnrolledPatients() {
        return this.enrolledPatients;
    }

    public void setEnrolledPatients(List<EnrolledPatients> enrolledPatients) {
        this.enrolledPatients = enrolledPatients;
    }

    @OneToMany(mappedBy = "protocoloCompromisopais")
    @LazyCollection(LazyCollectionOption.FALSE)
    public List<Objetivo> getObjetivos() {
        return this.objetivos;
    }

    public void setObjetivos(List<Objetivo> objetivos) {
        this.objetivos = objetivos;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof ProtocoloCompromisopais)) return false;

        ProtocoloCompromisopais that = (ProtocoloCompromisopais) o;

        if (!id.equals(that.id)) return false;

        return true;
    }

    @Override
    public int hashCode() {
        return id.hashCode();
    }

    @ManyToMany
    @LazyCollection(LazyCollectionOption.FALSE)
    public List<EquipmentSiteProtocoloCompromisoPais> getEquipments() {
        return equipments;
    }

    public void setEquipments(List<EquipmentSiteProtocoloCompromisoPais> equipments) {
        this.equipments = equipments;
    }
}